package net.zoneland.geological.devicedata.controller.excelreader;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import net.zoneland.common.excel.reader.IRowReader;
import net.zoneland.geological.devicedata.entity.Tbl_surface_move_device_data_manual;
import net.zoneland.geological.devicedata.service.Tbl_surface_move_device_data_manualServiceI;
import net.zoneland.greenleaf.GLOBAL;

/**
 * 地表位移数据导入
 * @author cmcc
 *
 */
public class SurfaceMoveDataImportExcelReader implements IRowReader{
	
	/* 业务逻辑实现方法
	 * @see net.zoneland.common.excel.reader.IRowReader#getRows(int, int, java.util.List)
	 */
	public void getRows( int sheetIndex, int curRow, List<String> cols, int startRow, Map<String, Object> paramMap ) {
		if( curRow < startRow ){
			return;
		}

		if( cols != null && !cols.isEmpty() ) {
			
			Tbl_surface_move_device_data_manualServiceI tbl_surface_move_device_data_manualService = (Tbl_surface_move_device_data_manualServiceI)GLOBAL.springContext.getBean("tbl_surface_move_device_data_manualService");
			
			//暂时读一行导入一行
			Tbl_surface_move_device_data_manual data = new Tbl_surface_move_device_data_manual();
			data.setX_move_value(Double.parseDouble(cols.get(0)));
			data.setY_move_value(Double.parseDouble(cols.get(1)));
			data.setZ_move_value(Double.parseDouble(cols.get(2)));
			data.setZht_id((String)paramMap.get("zhtId"));
			data.setHandle_time(new Date());
			
			try {
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
			    Date date = sdf.parse((String)cols.get(3));
				data.setObserve_time(date);
				
				tbl_surface_move_device_data_manualService.add(data);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
			System.out.println( "" );
		}
	}	
}
